//
//  RYYuShengzhangCell.swift
//  SheYangBigData
//
//  Created by 宋海胜 on 2021/1/13.
//  Copyright © 2021 叁拾叁. All rights reserved.
//

import UIKit

class RYYuShengzhangCell: SYBaseCell {

    var bgView: UIView = {
        let v: UIView = UIView()
        v.backgroundColor = .white
        return v
    }()
    
    var leftV: UIView = {
        let v: UIView = UIView()
        v.backgroundColor = .white
        v.backgroundColor = UIColor(hex: 0x808489)
        return v
    }()
    
    var rightV: UIView = {
        let v: UIView = UIView()
        v.backgroundColor = .white
        v.backgroundColor = UIColor(hex: 0x808489)
        return v
    }()
    
    var bottomV: UIView = {
        let v: UIView = UIView()
        v.backgroundColor = .white
        v.backgroundColor = UIColor(hex: 0x808489)
        v.isHidden = true
        return v
    }()

    
    let firLb: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x666666)
        v.font = 13.autoFontSize()
        return v
    }()
    
    let secLb: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x666666)
        v.font = 13.autoFontSize()
        return v
    }()
    
    let thirLb: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x666666)
        v.font = 13.autoFontSize()
        return v
    }()
    
    let qushitu: UIButton = {
        let v: UIButton  = UIButton()
        v.setTitle("趋势图", for: .normal)
        v.setTitleColor(UIColor(hex: 0x367FF6), for: .normal)
        v.titleLabel?.font = 12.autoFontSize()
        return v
    }()
    
    func configure(_ model: Sensors) {
        firLb.text = model.deviceName
        secLb.text = "\(model.currentValue ?? "0.0")\(model.unit ?? "")"
        thirLb.text = model.range ?? "无具体参考值"
    }
    
    override func initViews() {
        
        qushitu.addAction {[weak self] in
            if let `self` = self {
                
            }
        }
        addSubview(bgView)
        bgView.addSubview(firLb)
        bgView.addSubview(secLb)
        bgView.addSubview(thirLb)
        bgView.addSubview(qushitu)
        bgView.addSubview(leftV)
        bgView.addSubview(rightV)
        bgView.addSubview(bottomV)
        bgView.snp.makeConstraints { (make) in
            make.top.bottom.equalToSuperview()
            make.left.equalToSuperview().offset(15.autoWidth())
            make.right.equalToSuperview().offset(-15.autoWidth())
            make.height.equalTo(40.autoWidth())
        }
        leftV.snp.makeConstraints { (make) in
            make.left.top.bottom.equalToSuperview()
            make.width.equalTo(0.5.autoWidth())
        }
        rightV.snp.makeConstraints { (make) in
            make.right.top.bottom.equalToSuperview()
            make.width.equalTo(0.5.autoWidth())
        }
        bottomV.snp.makeConstraints { (make) in
            make.left.bottom.right.equalToSuperview()
            make.height.equalTo(0.5.autoWidth())
        }
        firLb.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(6.autoWidth())
            make.height.equalTo(15.autoWidth())
        }
        secLb.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(80.autoWidth())
            make.height.equalTo(15.autoWidth())
        }
        thirLb.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(163.autoWidth())
            make.height.equalTo(15.autoWidth())
        }
        qushitu.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.right.equalToSuperview().offset(-10.autoWidth())
            make.height.equalTo(15.autoWidth())
        }
    }

}
